package vaccine.appointment.system.vaccinationsite.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vaccine.appointment.system.common.annotation.AutoWrapResult;
import vaccine.appointment.system.common.annotation.RequireRole;
import vaccine.appointment.system.user.enums.IdentityInfoEnum;
import vaccine.appointment.system.vaccinationsite.dataobject.VaccinationSite;
import vaccine.appointment.system.vaccinationsite.service.VaccinationSiteService;
import vaccine.appointment.system.vaccinationsite.vo.VaccinationSiteVO;

import java.util.List;

/**
 * 接种点控制器
 */
@AutoWrapResult
@RequestMapping("/vaccinationsite")
@RestController
public class VaccinationSiteController {
    @Autowired
    private VaccinationSiteService vaccinationSiteService;

    @RequestMapping("/selectVaccinationSiteById")
    public VaccinationSite selectVaccinationSiteById(Integer id) {
        return vaccinationSiteService.selectVaccinationSiteById(id);
    }

    @RequestMapping("/add")
    public Boolean add(VaccinationSite vaccinationSite) {
        return vaccinationSiteService.add(vaccinationSite);
    }

    @RequestMapping("/del")
    public Boolean delete(Integer id) {
        return vaccinationSiteService.delete(id);
    }

    @RequestMapping("/update")
    public Boolean update(VaccinationSite vaccinationSite) {
        return vaccinationSiteService.update(vaccinationSite);
    }

    /**
     * 查询所有接种点
     * @return 接种点列表
     */
    @GetMapping("/list")
    @RequireRole({IdentityInfoEnum.NORMAL_USER, IdentityInfoEnum.HOSPITAL_ADMIN, IdentityInfoEnum.SUPER_ADMIN})
    public List<VaccinationSiteVO> getAllSites() {
        return vaccinationSiteService.getAllSites();
    }
}
